<?php namespace Home\Controller; 
use Hdphp\Controller\Controller;
//内容页控制器
class ContentController extends Controller{
    //内容页
    public function index(){
  		//接收get过来的aid
    	$aid = Q('get.aid',0,'intval');
		//刷新浏览次数+1
		$arcModel = new \Common\Model\Arc;
		$arcModel->where("aid={$aid}")->increment('click',1);
		//获得文章数据
		//文章表数据表关联
		$data = $arcModel->join('article_data','article_aid','=','aid')->where("aid={$aid}")->find();
		$arcTagModel = new \Common\Model\ArcTag;
		$data['tag'] = $arcTagModel->join('tag','tid','=','tag_tid')->where("article_aid={$aid}")->field('tid,tname')->get();
		//分配数据
//		p($data);exit;
		View::with('data',$data);
		$aidData = $arcModel->where("aid={$aid}")->get();
//		p($aidData);
		//上一篇文章
		$sData = $arcModel->orderBy('aid','DESC')->where("{$aid}>aid AND is_recycle=0 AND category_cid={$aidData[0]['category_cid']}")->limit(1)->get();
//		p($sData);
		View::with('sData',$sData);
		//下一篇文章
		$xData = $arcModel->where("{$aid}<aid AND is_recycle=0 AND category_cid={$aidData[0]['category_cid']}")->limit(1)->get();
//		p($xData);
		View::with('xData',$xData);
    	//载入模板
    	View::make();
	}
	
}